<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>hello_react</title>
</head>
<body>
    <div id="test"></div>

    <!-- 引入react核心库 -->
    <script type="text/javascript" src="../js/react.development.js"></script>
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <script type="text/javascript" src="../js/babel.min.js"></script>

    <script type="text/babel">
        class Dome extends React.Component {
            constructor(props) {
                super(props)
            }
            // 用于定义数据
            state = {isHot:true}
            render() {
                const {isHot} = this.state
                return (
                    <div><h1 onClick = {this.click}>今天天气很{this.state.isHot?'炎热':'凉爽'}</h1><div></div></div>
                )
            }
            click = ()=> {
                console.log(this)
                // this.state.isHot = !this.state.isHot
                // 在箭头函数下，函数中的this指向的是上一层，在这里是Dome的实例对象
                this.setState({isHot:!this.state.isHot})
            }
        }
        ReactDOM.render(<Dome/>,document.getElementById('test'))
    </script>
</body>
</html>